#ifndef TREE_HPP
#define TREE_HPP

#include <vector>
#include <string>
using namespace std;

#include "Node.hpp"

class Tree
{
private :
    Node* _root;
    Node* _selection;

    void selectNodeRec(Node* node, int x, int y, int xrep, int yrep);

    friend class Model;

public :
    Tree();
    Tree(const Tree& orig);
    ~Tree();

    const std::vector<Node*> getNodes(int startX, int startY,
                                      int endX, int endY) const;
    void addNodesToSelection(const std::vector<Node*>& selectedNodes);
    void clearSelection();

    void deleteSelectedNodes();

    bool selectNode(int x, int y);
    void moveSelectedNodesGraphically(int dx, int dy);
    bool areSelectedNodesMovableGraphically(int dx, int dy);

    Node* const getRoot() const;

    void redraw();

    void toString(std::ostringstream& s);
    void open(std::ifstream& i);

};

#endif // TREE_HPP
